﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExpressionEvaluator
{
	/// <summary>
	/// Collecion of code blocks.
	/// </summary>
	internal class CodeBlockCollection : List<CodeBlock>
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="CodeBlockCollection"/> class.
		/// </summary>
		/// <param name="originalCode">The original code.</param>
		public CodeBlockCollection(string originalCode)
		{
			OriginalCode = originalCode;
		}

		/// <summary>
		/// Gets or sets the original code.
		/// </summary>
		/// <value>The original code.</value>
		public string OriginalCode
		{
			get;
			private set;
		}

		/// <summary>
		/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </summary>
		/// <returns>
		/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </returns>
		public override string ToString()
		{
			StringBuilder result = new StringBuilder();
			foreach (CodeBlock codeBlock in this)
			{
				result.AppendLine(codeBlock.ToString());
			}
			return result.ToString();
		}
	}
}
